<template>
    <div class="order-product">
        <h2>Product</h2>

        <div class="product-title">
            <span>Product</span>
            <span>Color/Size</span>
            <span>Price</span>
            <span>Quantity</span>
            <span>Subtotal</span>
            <span>Actions</span>
        </div>

        <div class="product-list">

            <ul>
                <li v-for="(item, index) in tableData" :key="index" :class="{ active: item.visible }" :style="{ paddingBottom: getBrandList(item).length * 40 + 'px' }">

                    <div class="table-model">
                        <CommonTemplatePreview :pieces.sync="item.design_list" :baseColor="getItemColor(item)" :models="item.model_img" />
                        <span v-text="item.title" :title="item.title"></span>
                    </div>

                    <div class="table-select">

                        <p slot="reference" @click="triggerPopover(item, !item.visible)">
                            <span>Color :</span>
                            <em v-if="item.select_color" :style="{ backgroundColor: getItemColor(item).color_num }"></em>
                            <strong v-else>--</strong>
                            <br />
                            <span>Size :</span>
                            <strong v-text="getItemSize(item)"></strong>
                            <!-- <i class="iconfont icon-you" ></i> -->
                        </p>

                        <div class="table-select-popover">

                            <UxLoading v-if="item.loading" />

                            <div class="table-select-action" v-else-if="item.sku_list.length > 0">
                                <ul name="Color">
                                    <li v-for="color in item.color_list" :key="color.color_id" :class="{ active: item.cache_color == color.color_id }">
                                        <el-tooltip :content="color.color_name" placement="top">
                                            <button :style="{ backgroundColor: color.color_num }" :disabled="item.color_able.indexOf(color.color_id) < 0" @click="popoverClick(item, 'color', color)"></button>
                                        </el-tooltip>
                                        <svg-icon name="checkbox-active-shadow" />
                                    </li>
                                </ul>

                                <ul name="Size">
                                    <li v-for="size in item.size_list" :key="item.size_id + '-' + size.size_id" :class="{ active: item.cache_size == size.size_id }">
                                        <button :disabled="item.size_able.indexOf(size.size_id) < 0" v-text="size.size_name" @click="popoverClick(item, 'size', size)"></button>
                                    </li>
                                </ul>

                                <button v-show="item.cache_size && item.cache_color" :disabled="!item.cache_size || !item.cache_color" @click="triggerPopover(item, false)" type="primary">OK</button>
                            </div>

                            <div class="table-select-nodata" v-else>
                                <strong>Failed to load sku information</strong>
                                <button @click="triggerPopover(item, true)">reload</button>
                            </div>
                        </div>
                    </div>

                    <div class="table-cost">
                        <CommonLevelDiscount :blank="item.is_blank" :price="getPriceFormat(item)" :level="levelInfo" type="unit|original|discount" />
                    </div>

                    <div class="table-quantity">
                        <UxInputNumber v-model="item.quantity" :step="1" :min="1" />
                    </div>

                    <div class="table-cost">
                        <CommonLevelDiscount :blank="item.is_blank" :price="getPriceFormat(item)" :count="item.quantity" :level="levelInfo" type="unit|original|discount" />
                    </div>

                    <div class="table-operate">
                        <el-tooltip content="Copy product" placement="top">
                            <button class="iconfont icon-fuzhi" @click="insertDesign([item], 'copy')"></button>
                        </el-tooltip>
                        <el-tooltip content="Remove product" placement="top">
                            <button class="iconfont icon-liebiao-shanchu" @click="doDelItem(item)"></button>
                        </el-tooltip>
                    </div>

                    <div class="table-brand" v-for="brand in getBrandList(item)" :key="brand.type + index + brand.id">

                        <div></div>
                        <div class="table-brand-name">
                            <img v-if="brand.type == 'pack'" src="https://img.podpartner.com/static/images-20230202/brand/package-icon.png" alt="">
                            <img v-if="brand.type == 'tag'" src="https://img.podpartner.com/static/images-20230202/brand/hangtag-icon.png" alt="">
                            <span v-text="brand.template_name"></span>
                        </div>
                        <!-- <CommonCurrencyRate :price="brand.total_price" /> -->
                        <CommonLevelDiscount :price="brand.total_price" :level="levelInfo" type="unit|original|discount" />
                        <div class="table-cost" v-text="item.quantity"></div>
                        <CommonLevelDiscount :price="brand.total_price" :count="item.quantity" :level="levelInfo" type="unit|original|discount" />
                        <div class="table-brand-remove">
                            <button @click="closeBrand(item, brand)"><svg-icon name="dialog-close-medium" /></button>
                        </div>
                    </div>

                </li>
            </ul>

        </div>

        <div class="product-add" @click="selectProduct = true">
            <svg-icon name="user-template" />
            <span>Add product</span>
        </div>

        <section class="product-footer">
            <div class="product-footer-total" :level="pricing.level_num">
                <span>{{ priceTotal.count }} product(s)</span>
                <strong>Total: {{ currency }}</strong>
                <strong name="original" v-text="priceTotal.original"></strong>
                <CommonLevelDiscount :level="pricing.level_num" :other="{pre:priceTotal.discount}" type="pre|icon" />
            </div>
            <div class="product-footer-btn">
                <button @click="$router.go(-1)">Cancel</button>
                <button type="primary" :class="{ disabled: disabled }" @click="doNext">
                    <span>Edit shipping info</span>
                    <UxLoading :loading="loading" size="24px" />
                </button>
            </div>
        </section>

        <!-- 选择图片弹窗 -->
        <OrderProductSelect v-model="selectProduct" :levelInfo="levelInfo" @selectDesign="insertDesign($event, 'insert')" />
    </div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
export default {
    name: "OrderProduct",
    layout: "layout-logined",
    data () {
        return {
            loading: false,
            selectProduct: false,
            tableData: [],
        };
    },
    computed: {
        ...mapState({
            currency: 'currency',
            rate: 'rate',
        }),
        ...mapGetters("order", {
            shopId: "getShopId",
            product: "getProduct",
            address: "getAddress",
            pricing: 'getPricing',
        }),
        levelInfo () {
            const pricing = this.pricing || {}
            return {
                user_level: pricing.level_num,
                user_discount: pricing.level_discount,
            }
        },
        // 是否允许创建
        disabled () {
            // 每个数量大于1，且已经选择了颜色
            // 判断商品有没有尺寸和颜色
            if (this.tableData.length == 0) {
                return true;
            } else {
                let unready = this.tableData.filter((item) => {
                    // 显示选择颜色弹窗的
                    // 没有选择颜色
                    // 没有选择尺码
                    // 没有价格
                    // 没有数量
                    return item.visible || !item.select_color || !item.select_size || item.price <= 0 || item.quantity <= 0
                });

                return unready.length > 0;
            }
        },

        priceTotal () {
            const pricing = this.pricing;
            const amount = pricing.product + pricing.tag_original + pricing.pack_original;
            const discount = pricing.level_price

            return {
                amount: amount * this.rate,
                original: (0.01 * amount * this.rate).toFixed(2),
                discount: (0.01 * discount * this.rate).toFixed(2),
                count: pricing.count,
            };
        },
    },
    watch: {
        tableData: {
            deep: true,
            handler (v) {
                this.$store.commit("order/SET_PRODUCT", this.tableData);
            },
        },
    },
    methods: {


        //通过store获取table
        getTableData () {
            this.tableData = this.product.map((item) => {
                const result = {
                    ...item,
                    sku_list: item.sku_list || [],
                    select_color: item.select_color || '',
                    select_size: item.select_size || '',
                    sku: item.sku || '',
                    stock: item.stock || 0,
                    price: item.price || 0,
                    quantity: item.quantity || 1,
                    weight: item.weight || 0,

                    visible: false, // 弹窗选择颜色和尺码
                    loading: false, // 加载中
                    color_able: [], // 可用的颜色
                    size_able: [], // 可用的尺码
                    cache_size: '',
                    cache_color: '',
                    rowspan: 1,
                }

                this.formatSpu(result)

                if (!result.select_color || !result.select_size) {
                    result.visible = true;
                    this.$nextTick(e => this.triggerPopover(result, true))
                } else {
                    this.popoverClick(item)
                }

                return result;
            });
        },

        // 格式化库存
        formatSpu (item) {

            const size_map = new Map()
            const color_map = new Map();
            item.sku_list.map(item => {
                size_map.set(item.size_id, item)
                color_map.set(item.color_id, item)
            });

            const size_list = Array.from(size_map.values()).sort((a, b) => a.size_sort - b.size_sort);
            const color_list = Array.from(color_map.values()).sort((a, b) => a.color_sort - b.color_sort);
            const color_base = item.select_color || item.color_base || '';
            const color_select = color_list.filter((i) => i.color_id == color_base)[0] || color_list[0];


            // 有基础色
            // 如果未选中颜色，则先选中基础色
            // TODO 如果基础色库存不足，也不能选中
            item.color_list = color_list;
            item.size_list = size_list;
            item.select_color = color_select ? color_select.color_id : '';
            item.cache_color = item.select_color;
            item.loading = false;

        },
        // 选中节点
        popoverClick (item, type, option) {

            // 显示禁用
            const getAble = () => {

                // 只有大于-999的才可以计算
                const sku_list = item.sku_list.filter(i => i.quality > -999);

                const color_filter = item.cache_size ? sku_list.filter(i => i.size_id == item.cache_size) : item.color_list;
                const color_able = color_filter.map(item => item.color_id);

                const size_filter = item.cache_color ? sku_list.filter(i => i.color_id == item.cache_color) : item.size_list;
                const size_able = size_filter.map(item => item.size_id);

                return {
                    color: color_able,
                    size: size_able,
                }
            }

            const currentAble = getAble();

            if (type == 'size') {
                currentAble.size.indexOf(option.size_id) >= 0 && (item.cache_size = option.size_id);
            } else if (type == 'color') {
                currentAble.color.indexOf(option.color_id) >= 0 && (item.cache_color = option.color_id);
            }

            item.color_able = getAble().color;
            item.size_able = getAble().size;

        },


        getPriceFormat (item) {
            let price = parseFloat(item.price) || 0;
            let extra = parseFloat(item.extra_price) || 0;
            let result = price + extra;
            if (!item.select_size || !item.select_color || !price) {
                return "--";
            } else if (result) {
                return result;
            } else {
                return "--";
            }
        },


        getBrandList (item) {

            const result = []
            if (item.tag && item.tag_price) {
                // result.rowspan += 1;
                result.push({ ...item.tag, type: 'tag' })
            }
            if (item.pack && item.pack_price) {
                result.push({ ...item.pack, type: 'pack' })
            }
            return result;
        },


        // 取消包装
        closeBrand (item, brand) {
            if (brand.type == 'tag') {
                item.tag_price = 0;
            } else if (brand.type == 'pack') {
                item.pack_price = 0;
            }
        },

        // 打开选择颜色弹窗
        triggerPopover (item, open) {

            if (!open) {
                // 是否打开选择弹窗
                const select = item.sku_list.filter(i => item.cache_size == i.size_id && item.cache_color == i.color_id)[0];

                item.visible = false;
                item.select_size = item.cache_size;
                item.select_color = item.cache_color;

                item.sku = select.sku;
                item.stock = parseInt(select.quality || 0) + 99; // 库存默认加99
                item.price = select.price;
                item.quantity = item.quantity || 1;
                item.weight = parseFloat(select.weight) || 0;

            } else if (item.sku_list && item.sku_list.length > 0) {
                // 已经有数据不用加载
                item.visible = true;
                item.cache_size = item.select_size;
                item.cache_color = item.select_color;
                this.popoverClick(item)
            } else {

                item.loading = true;
                item.visible = true;
                this.$http('Product.getDetailInventory/' + item.spu).then(response => {
                    item.sku_list = response.data || [];
                    item.loading = false;
                    this.formatSpu(item);
                    this.popoverClick(item)

                }).catch(error => {
                    item.sku_list = [];
                    item.loading = false;
                })

            }
        },

        //删除单个订单
        doDelItem (item) {
            let index = this.tableData.indexOf(item);
            this.tableData.splice(index, 1);
            // this.$store.dispatch("order/delSampleListItem", index);
        },
        // 添加设计的模板
        insertDesign (products, type) {
            const list = this.product.slice(0);
            products.map(item => {
                const product = {
                    spu: item.spu, // 商品的spu
                    title: item.title, //标题
                    model_img: item.model_img, // 模特列表
                    design_list: item.design_list, //设计面信息
                    source: item.source, //商品来源
                    product_id: item.product_id, // 如果来源是商品，则有商品id
                    design_id: item.design_id, // 如果来源是设计的模板，则有设计id
                    color_base: item.color_base, // 基础色
                    extra_price: item.extra_price, // 设计面价格
                    is_blank: item.is_blank, // 是否空白模板

                    sku_list: item.sku_list || [], // sku 列表
                    color_list: item.color_list || [], //颜色列表
                    size_list: item.size_list || [], //尺码列表

                    select_color: item.select_color || '', //选择的颜色
                    select_size: item.select_size || '', //选择的尺码
                    sku: item.sku || '', //商品的sku
                    stock: item.stock || 0, //商品的库存
                    weight: item.weight || 0, //商品的克重kg
                    price: item.price || 0, // 价格
                    quantity: item.quantity || 1, //数量

                    tag: null,
                    pack: null,
                    tag_price: 0,
                    pack_price: 0,
                }

                if (type == 'copy') {

                    product.tag = item.tag;
                    product.tag_price = item.tag_price;
                    product.pack = item.pack;
                    product.pack_price = item.pack_price;
                } else if (type == 'insert') {

                    product.tag = item.tag_design_info;
                    product.tag_price = parseInt(product.tag ? product.tag.total_price : 0);
                    product.pack = item.pack_design_info;
                    product.pack_price = parseInt(product.pack ? product.pack.total_price : 0);

                }
                list.push(product);
            })

            this.$store.commit("order/SET_PRODUCT", list);
            this.getTableData();

        },

        // 获取颜色信息
        getItemColor (item) {
            let select = item.color_list.filter((i) => i.color_id == item.select_color)
            return select[0];
        },

        // 获取尺码信息
        getItemSize (item) {
            if (item.select_size) {
                let select = item.size_list.filter(
                    (i) => i.size_id == item.select_size
                )[0];
                if (select) {
                    return select.size_name;
                } else {
                    return "--";
                }
            } else {
                return "--";
            }
        },

        getItemCost (item) {
            let price = parseFloat(item.price) || 0;
            let extra = parseFloat(item.extra_price) || 0;
            let query = parseInt(item.quantity) || 0;
            let result = (price + extra) * query;

            if (!item.select_size || !item.select_color || !price) {
                return "--";
            } else if (result) {
                return result;
            } else {
                return "--";
            }
        },

        //跳转
        doNext () {

            let type = '';
            this.tableData.filter((item) => {
                if (!item.select_color) {
                    // 没有选择颜色
                    type = type || 'color';
                } else if (!item.select_size) {
                    // 没有选择尺码
                    type = type || 'size';
                }
            });

            if (this.loading) {
                // 如果正在加载中，则不重复加载
            } else if (this.tableData == 0) {
                // 为空
                this.$uxMessage.warning("Please select at least one item");
            } else if (type == 'size') {
                // 没有选择中尺码
                this.$uxMessage.warning("Please select product sizes");
            } else if (type == 'color') {
                // 没有选择中颜色
                this.$uxMessage.warning("Please select product colors");
            } else {

                this.loading = true;
                this.$store.dispatch("order/setShippingInit").then(res => {
                    this.loading = false;
                    this.$store.commit("order/SET_ADDRESS_TAB", this.shopId > 0 ? 'edit' : 'list');
                    this.$router.push("/order/shipping");

                }).catch(error => {
                    this.loading = false;
                    this.$uxMessage.warning(error.msg || "Failed to get your address");
                })

            }
        },

    },
    created () {
        if (process.client) {
            window.scrollTo(0, 0)
            this.getTableData();
        }
    },
};
</script>

<style lang="scss" scoped>
.order-product {
    display: flex;
    max-width: 1080px;
    margin: 0 auto;
    flex-direction: column;
    padding-bottom: 194px;

    & > h2 {
        margin: 40px 0;
        font-size: 32px;
        font-family: Roboto-Medium, Roboto;
        font-weight: 500;
        color: #000000;
        line-height: 40px;
    }
}

.product-title span,
.product-list li > div,
.table-brand > div {
    box-sizing: border-box;

    &:nth-child(1) {
        width: 16.7%;
    }

    &:nth-child(2) {
        width: 24.5%;
    }

    &:nth-child(3) {
        width: 15%;
    }

    &:nth-child(4) {
        width: 11.2%;
    }

    &:nth-child(5) {
        width: 15%;
    }

    &:nth-child(6) {
        width: 17.6%;
    }
}

.product-title {
    display: flex;
    height: 40px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e5e5;

    span {
        box-sizing: border-box;
        font-size: 14px;
        font-family: Roboto-Medium, Roboto;
        font-weight: 500;
        color: #292929;
        line-height: 20px;
        padding: 10px;
        text-align: center;
    }
}

.product-list {
    position: relative;
    overflow: hidden;

    & > ul > li {
        margin-top: 12px;
        display: flex;
        align-items: center;
        background: #ffffff;
        border-radius: 8px;
        border: 1px solid #e5e5e5;
        position: relative;

        &::after {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background: rgb(0, 0, 0, 0.25);
            border-radius: 8px;
            opacity: 0;
            pointer-events: none;
            transition: all 0.2s;
        }

        &.active {
            &::after {
                opacity: 1;
                pointer-events: all;
            }

            .table-select > p {
                background-color: #efefef;
            }

            .table-select-popover {
                opacity: 1;
                pointer-events: all;
            }
        }
    }

    .table-model {
        padding: 12px;

        .template-preview {
            max-width: 160px;
        }

        .table-model-img {
            height: 160px;
            width: 160px;
            background: #f7f7f7;
            border-radius: 6px;
            overflow: hidden;
            display: block;
            margin: 0 auto;
        }

        span {
            margin-top: 12px;
            text-align: center;
            font-size: 14px;
            color: #000;
            line-height: 16px;
            max-height: 32px;
            overflow: hidden;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            line-clamp: 2;
            text-overflow: ellipsis;
            -webkit-line-clamp: 2;
        }
    }

    .table-select {
        position: relative;
        display: flex;
        justify-content: center;

        & > p {
            display: inline-block;
            padding: 24px 18px;
            text-align: left;
            line-height: 30px;
            font-size: 14px;
            width: 78px;

            color: #666666;
            white-space: nowrap;
            position: relative;
            border-radius: 6px;
            cursor: pointer;
            user-select: none;
            background-color: #f0f0f0;
            font-size: 0;

            span {
                display: inline-block;
                vertical-align: top;
                width: 43px;
                margin-right: 10px;
                text-align: right;
                font-size: 14px;

                white-space: nowrap;
                color: #000000;

                &:first-child {
                    margin-bottom: 6px;
                }
            }

            strong {
                display: inline-block;
                vertical-align: top;
                min-width: 24px;
                text-align: center;
                font-size: 14px;

                color: #000000;
                font-weight: normal;
                position: relative;
            }

            em {
                display: inline-block;
                vertical-align: top;
                margin-top: 3px;
                position: relative;
                width: 24px;
                height: 24px;
                border-radius: 2px;
                box-sizing: border-box;
                border: 1px solid rgba(0, 0, 0, 0.2);
            }

            i {
                position: absolute;
                right: 0;
                top: 50%;
                transform: translateY(-50%);
                width: 44px;
                height: 46px;
                text-align: center;
                line-height: 44px;
                font-size: 18px;
                background: #ffffff;
                border-radius: 3px;
                border: 1px solid #f2f2f2;
            }

            &:hover:before {
                content: '';
                position: absolute;
                left: 0;
                top: 0;
                bottom: 0;
                right: 0;
                border-radius: 3px;
                background: rgba(0, 0, 0, 0.2);
                pointer-events: none;
            }
        }
    }

    .table-cost {
        font-size: 14px;
        color: #000000;
        line-height: 16px;
        text-align: center;

        .level-discount {
            font-size: 14px;

            &[currency='JPY'] {
                flex-wrap: wrap;

                &::v-deep span {
                    width: 100%;
                    margin: 2px 0;
                    text-align: center;
                }
            }
        }
    }

    .table-quantity {
        .input-number {
            width: 100px;
            margin: 0 auto;

            &::v-deep input {
                text-align: center;
                border-radius: 8px;

                &:hover {
                    border-color: #c7c7c7;
                }

                &:focus {
                    border-color: #f6b2cd;
                    box-shadow: 0 0 1px 1px #f6b2cd;
                }
            }
        }
    }

    .table-operate {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;

        button {
            width: 34px;
            height: 34px;
            margin: 0 6px;
            font-size: 26px;
            line-height: 34px;
            text-align: center;
            color: #737373;
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
            font-weight: normal;

            &:hover {
                color: #ea4c89;
            }
        }
    }

    .table-brand {
        position: absolute;
        left: 0;
        bottom: 0;
        right: 0;
        height: 40px;
        display: flex;
        align-items: center;
        background: #faf6eb;
        border-radius: 0 0 8px 8px;
        border-top: 1px solid #f0ebdf;
        box-sizing: border-box;

        & + .table-brand {
            bottom: 40px;
            border-radius: 0;
        }

        .table-brand-name {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;

            span {
                font-size: 12px;
                font-family: Roboto-Regular, Roboto;
                font-weight: 400;
                color: #000000;
                line-height: 16px;
                width: 96px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            img {
                width: 16px;
                height: 16px;
                border-radius: 16px;
                margin-right: 4px;
            }
        }

        .level-discount {
            font-size: 12px;
            font-family: Roboto-Regular, Roboto;
            font-weight: 400;
            line-height: 16px;
        }

        .table-brand-remove {
            display: flex;
            justify-content: center;

            button {
                border: none;
                vertical-align: top;
                height: 24px;
                overflow: hidden;
                margin: 0;
                height: 24px;
                color: #555;

                &:hover {
                    color: #8c1c14;
                }
            }

            svg {
                width: 10px;
                height: 10px;
            }
        }

        .currency-rate {
            color: #000;
        }
    }

    td {
        position: relative;
        padding: 12px 0;
        border: none;
        background: rgba(250, 241, 212, 0.36);
        font-size: 14px;
        color: #000000;
        line-height: 24px;
        height: 48px;
        box-sizing: border-box;

        &::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            height: 1px;
            background: #f0ebdf;
        }

        &:nth-child(1) {
            text-align-last: left;
            padding: 0 48px;
        }
    }
}

.table-select-popover {
    height: 200px;
    min-width: 260px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: 66px;
    transform: translateY(-50%);
    box-shadow: 2px 3px 6px 1px rgb(0 0 0 / 35%);
    background: #fff;
    border-radius: 5px;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;

    &::before {
        content: ' ';
        border-width: 6px;
        position: absolute;
        display: block;
        width: 0;
        height: 0;
        border-color: transparent;
        border-style: solid;
        top: 50%;
        margin-top: -6px;
        left: -6px;
        border-right-color: #fff;
        border-left-width: 0;
    }

    .table-select-action {
        padding: 14px 18px;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;

        ul {
            display: flex;
            width: 100%;
            padding-top: 18px;
            position: relative;

            &::before {
                content: attr(name) '';
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 14px;
                font-size: 12px;
                color: #555;
                line-height: 14px;
                text-indent: 6px;
                margin-bottom: 2px;
                text-align: left;
            }

            & + ul {
                margin-top: 8px;
            }

            &:first-child li {
                margin: 6px;
                position: relative;
                cursor: pointer;

                button {
                    display: block;
                    width: 24px;
                    height: 24px;
                    background: #5c323e;
                    border-radius: 2px;
                    border: 1px solid rgba(0, 0, 0, 0.06);
                    position: relative;

                    &[disabled] {
                        cursor: not-allowed;

                        &:hover {
                            background: #f6f6f6;
                            border-color: #dcdcdc;
                            color: #919191;
                        }

                        &::after {
                            content: '';
                            position: absolute;
                            left: 0;
                            top: 0;
                            width: 100%;
                            height: 100%;
                            background-repeat: no-repeat;
                            background-position: center center;
                            background-image: url('');
                            background-color: rgba(0, 0, 0, 0.12);
                            border-radius: 2px;
                        }
                    }
                }

                svg {
                    display: none;
                    position: absolute;
                    width: 18px;
                    height: 18px;
                    color: #fff;
                    text-align: center;
                    line-height: 18px;
                    left: 50%;
                    top: 50%;
                    transform: translate(-50%, -50%);
                    font-size: 18px;
                    text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
                }

                &:hover {
                    box-shadow: 0 0 3px solid #ea4c89;
                }

                &.active svg {
                    display: block;
                }
            }

            &:nth-child(2) li {
                user-select: none;
                box-sizing: border-box;
                margin: 8px 4px 0;
                width: 42px;
                display: flex;
                align-items: center;
                justify-content: center;
                height: 32px;
                box-sizing: border-box;

                button {
                    height: 32px;
                    width: 42px;
                    padding: 0;
                    font-size: 12px;
                    border-radius: 4px;
                    font-weight: normal;
                }

                &.active button {
                    color: #ea4c89;
                    border-color: #ea4c89;
                }

                button[disabled] {
                    cursor: not-allowed;

                    &:hover {
                        background: #f6f6f6;
                        border-color: #dcdcdc;
                        color: #919191;
                    }
                }
            }
        }

        & > button {
            margin: 20px auto 0;
            width: 220px;
            height: 32px;
            font-weight: normal;
        }

        & > cite {
            display: block;
            margin: 20px 0 0;
            height: 32px;
            text-align: center;

            button {
                width: 220px;
                height: 32px;
            }
        }
    }

    .table-select-nodata {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        align-items: center;

        strong {
            display: flex;
            flex-direction: column;
            font-size: 16px;
            text-align: center;
            line-height: 40px;
            font-weight: normal;
        }

        button {
            margin-top: 8px;
            height: 30px;
            width: 80px;
        }
    }

    .loading {
        border-radius: 6px;
    }
}

.product-add {
    margin-top: 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: 108px;
    border-radius: 8px;
    border: 1px dashed #b3b3b3;
    color: #000;
    cursor: pointer;
    transition: all 0.2s;

    span {
        font-size: 16px;
        font-family: Roboto-Medium, Roboto;
        font-weight: 500;
        line-height: 20px;
    }

    svg {
        margin-right: 4px;
        width: 20px;
        height: 20px;
    }

    &:hover {
        border-color: transparent;
        background: #ffffff;
        box-shadow: 0px 4px 6px 0px rgba(0, 0, 0, 0.08);
        color: #ea4c89;
    }
}

.product-footer {
    height: 120px;
    z-index: 1;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100vw;
    background-color: #fff;
    border-top: 1px solid #e6e6e6;
    display: flex;
    flex-direction: column;
    justify-content: center;

    .product-footer-total {
        display: flex;
        justify-content: center;
        align-items: center;
        line-height: 24px;
        color: #000;

        & > span {
            margin-right: 12px;
            font-size: 16px;
            font-family: Roboto-Regular, Roboto;
            font-weight: 400;
            color: #555555;
            line-height: 24px;
        }

        & > strong {
            font-size: 18px;
            font-family: Roboto-Regular, Roboto;
            font-weight: 400;
            color: #000000;
            line-height: 24px;
            margin-right: 6px;

            &[name='original'] {
                text-decoration: line-through;
            }
        }

        & > .level-discount::v-deep > span[name='icon'] {
            width: 24px;
            height: 24px;
            background-size: 24px 24px;
            margin: 0;
        }

        &[level='1'] {
            & > strong[name='original'] {
                display: none;
            }

            // & > .level-discount {
            //     display: none;
            // }
        }
    }

    .product-footer-btn {
        display: flex;
        flex-direction: row;
        justify-content: center;
        margin-top: 16px;

        button {
            width: 108px;
            height: 40px;
            margin: 0 6px;
            position: relative;

            &:nth-child(2) {
                width: 180px;
                height: 40px;
            }
        }
    }
}
</style>
